//
//  LeGameObjectManager.h
//  Leste
//
//  Created by 王乐 on 2022/1/28.
//

#ifndef LeGameObjectManager_hpp
#define LeGameObjectManager_hpp

#include <map>
#include <vector>

class LeGameObject;

class LeGameObjectManager
{
public:
    LeGameObjectManager();
    ~LeGameObjectManager();


public:
    // Initialize All Starting GameObjects HERE !
    // ------------------------------------------
    void initializeGameObjects();  // Initialize gameobjects
    void initializeLeste();
    void initializeCAD();
    void initializeParticleDemo();
    void initializePostProcessingDemo();
    void initializePhysicsDemo();
    
    // Iterate Over All GameObjects to do stuff
    // ----------------------------------------
    void Awake();       // Before gameloop, right after GameOjbect initialized.
    void PreRender();   // Before gameLoop.
    void Start();       // Before gameloop.
    void RenderSelection(); // In gameloop.
    void updateCurMouseHoverID(); // In gameloop
    void Update();      // In gameloop.
    void PostWorldStep();//In gameloop.
    void FixedUpdate(); // In gameloop.
    void Render();      // In gameloop.
    void PostRender();  // After gameloop.
    
    void PostprocessingSetup();
    
public:
    // Add and Initialize gameobject. Initilize(), Awake(), PreRender(), Start() also happen here.
    void addGameObject(LeGameObject* pgameobj);

    LeGameObject *findGameObjectByID(unsigned int id);
    void destroyGameObjectByID(unsigned int id);
    
    void addGameObjIDtoDestroy(unsigned int id);
    void destroyGameObjectsByIDs();

    unsigned int getCurMouseHoverId() const;
    
private:
    unsigned int m_CurID;
    std::map<unsigned int, LeGameObject*> m_pMapGameObjects;
    
    std::vector<unsigned int> m_arrGameObjIDstoDestroy;

    unsigned int m_CurMouseHoverID;
};

#endif /* LeGameObjectManager_hpp */
